<?php

class SiteController extends Controller
{
	public $layout='//layouts/main';

	/**
	 * Declares class-based actions.
	 */
	public function actions()
	{
		return array(
			'page'=>array(
				'class'=>'CViewAction',
			),
		);
	}

	/**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
	    if($error=Yii::app()->errorHandler->error)
	    {
	    	if(Yii::app()->request->isAjaxRequest)
	    		echo $error['message'];
	    	else
	        	$this->render('error', $error);
	    }
	}

	/**
	 * Default action
	 */
	public function actionIndex()
	{
		$manufacturers = Catalog::getManufacturers();
		$models = array();
		foreach($manufacturers as $id => $val)
		{
			$models[$id] = Catalog::getModels($id);
		}
		
		$this->render('index', array(
			'manufacturers'=>$manufacturers,
			'models'=>$models,
		));
	}
}
